<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<base href="${pageContext.request.scheme }://${pageContext.request.serverName}:
${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
<html>
<head>
<meta charset="UTF-8">
<title>会员登录页面</title>
<link type="text/css" rel="stylesheet" href="static/css/style.css" >
<script type="text/javascript">
	window.onload=function(){
		var username=document.getElementById("username");
		var password=document.getElementById("password");
		
		var unameMsg=document.querySelector(".unameMsg");
		var pwdMsg=document.querySelector(".pwdMsg");
		var unameFlag=false;
		var pwdFlag=false;
		
		var sub_btn=document.getElementById("sub_btn");
		
		username.onfocus=function(){
			showMsg(unameMsg,"请输入用户名","blue");
		}
		username.onblur=function(){
			//鼠标离开的时候，去除文本框中数据的空格
			var newUsername=username.value.replace(/[ ]/g,"");
			//把去除空格后的数据，放在用户名文本框中
			username.value=newUsername;
			if(username.value==""){
				showMsg(unameMsg,"用户名不能为空","red");
				unameFlag=false;
			}else{
				showMsg(unameMsg,"√","blue");
				unameFlag=true;
			}
		}
		password.onfocus=function(){
			showMsg(pwdMsg,"请输入密码","blue");
		}
		password.onblur=function(){
			//鼠标离开的时候，去除文本框中数据的空格
			var newpassword=password.value.replace(/[ ]/g,"");
			//把去除空格后的数据，放在用户名文本框中
			password.value=newpassword;
			if(password.value==""){
				showMsg(pwdMsg,"密码不能为空","red");
				pwdFlag=false;
			}else{
				showMsg(pwdMsg,"√","blue");
				pwdFlag=true;
			}
		}
		
		sub_btn.onclick=function(){
			if(unameFlag=true&& pwdFlag==true){
				return true;
			}else{
				username.onblur();password.onblur();
				return false;
			}
		}
	}
	
	function showMsg(ele,msg,co){
		ele.innerHTML=msg;
		ele.style.color=co;
	}
</script>
</head>
<body>
			<div class="login_banner">
			
				<div id="l_content">
					<span class="login_word">欢迎登录</span>
				</div>
				
				<div id="content">
					<div class="login_form">
						<div class="login_box">
							<div class="tit">
								<h1>会员登录</h1>
								<a href="regist.jsp">立即注册</a>
							</div>

							<div class="msg_cont">
								<b></b>
								<span style="color: red">${errorMsg}</span>
								${pageContext.session.removeAttribute("errorMsg")}
							</div>
							<div class="form">
								<form action="UserServlet" method="post">
									<input type="hidden" name="way" value="doLogin">
									<label>用户名称：</label>
									<input class="itxt" type="text" placeholder="请输入用户名" name="username" value="${user.username}"
										   autocomplete="off" tabindex="1" id="username" />
									${pageContext.session.removeAttribute("user")}
									<span class="unameMsg"></span>
									<br />
									<br />
									<label>用户密码：</label>
									<input class="itxt" type="password" placeholder="请输入密码" name="password" value="" autocomplete="off" tabindex="1" id="password" />
									<span class="pwdMsg"></span>
									<br />
									<br />
									<input type="submit" value="登录" id="sub_btn" />
								</form>
							</div>
							
						</div>
					</div>
				</div>
			</div>
		<div id="bottom">
		</div>
</body>
</html>